package com.amc.utils;

import java.io.IOException;
import java.util.List;

import com.amc.entity.Merchant;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class JsonUtil {
	private static ObjectMapper mapper = new ObjectMapper();
	
	public static String listToString(List<String> list) {
		String data = null;
		try {
			data = mapper.writeValueAsString(list);
		} catch (JsonProcessingException e) {
			e.printStackTrace();
		}
		return data;
	}
	
	public static Merchant jsonToObject(String json) {
		Merchant merchant = null;
		try {
			merchant = mapper.readValue(json, Merchant.class);
		} catch (JsonParseException e) {
			e.printStackTrace();
		} catch (JsonMappingException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return merchant;
	}

}
